import { getRequestIp } from '@/pages/AssetManage/Acommon';
import { getUserDepID, requestFunComponFiex } from '@/utils';
import { useRequest } from 'umi';

export const getProjectService = () => {
  const request = useRequest(
    (payload: Record<string, any>) => {
      let reqParams: Record<string, any> = {
        current: 1,
        pageSize: 10,
        sort: 'KSRQ',
        order: 'desc',
        BMDM: getUserDepID(),
        // GSDM: getCompanyID(),
        ...payload,
      };
      let reqUrl = `${getRequestIp()}/contractController/getProject`;
      return requestFunComponFiex('POST', reqUrl, reqParams);
    },
    {
      manual: true,
      paginated: true,
      defaultPageSize: 10,
    },
  );
  return {
    getProjectRun: request.run,
    getProjectLoading: request.loading,
    getProjectPagination: request.pagination,
  };
};
